import java.util.Scanner;
public class Main {

    //求阶乘和
    public  static int calculateFactorialSum(int n){
        int sum1 = 0;
        for (int i = 1; i <= n; i++) {
            sum1 += factorial(i);
        }
        return sum1;
    }
//单个阶乘和
    public  static int factorial(int n){
        int sum2 = 1;
        for (int i = 1; i <= n; i++) {
            sum2 *= i;
        }
        return sum2;
    }
    public static void main(String[] args) {
        Scanner jc = new Scanner(System.in);
        System.out.println("你想求多少阶乘的和:");
        int jch = jc.nextInt();  //读入一行

        System.out.println("前n阶乘的和为："+ calculateFactorialSum(jch));
    }
}